<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>任务中心 - 学术科研管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f7fa;
            color: #333;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        .header h1 {
            margin: 0;
            font-size: 24px;
        }

        .container {
            max-width: 1400px;
            margin: 20px auto;
            padding: 0 20px;
        }

        .toolbar {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
        }

        .search-box {
            display: flex;
            gap: 10px;
            align-items: center;
            flex-wrap: wrap;
        }

        .search-box input, .search-box select {
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
        }

        .search-box input {
            width: 300px;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-block;
            text-align: center;
        }

        .btn-primary {
            background: #007bff;
            color: white;
        }

        .btn-primary:hover {
            background: #0056b3;
        }

        .btn-success {
            background: #28a745;
            color: white;
        }

        .btn-success:hover {
            background: #1e7e34;
        }

        .btn-warning {
            background: #ffc107;
            color: #212529;
        }

        .btn-warning:hover {
            background: #e0a800;
        }

        .btn-danger {
            background: #dc3545;
            color: white;
        }

        .btn-danger:hover {
            background: #c82333;
        }

        .btn-sm {
            padding: 5px 10px;
            font-size: 12px;
        }

        .tasks-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
            gap: 20px;
        }

        .task-card {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            padding: 20px;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .task-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        }

        .task-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 15px;
        }

        .task-title {
            font-size: 18px;
            font-weight: 600;
            color: #333;
            margin: 0;
            flex: 1;
            margin-right: 10px;
        }

        .task-priority {
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }

        .priority-urgent {
            background: #ffebee;
            color: #c62828;
        }

        .priority-high {
            background: #fff3e0;
            color: #ef6c00;
        }

        .priority-medium {
            background: #e8f5e8;
            color: #2e7d32;
        }

        .priority-low {
            background: #e3f2fd;
            color: #1565c0;
        }

        .task-meta {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-bottom: 15px;
            font-size: 14px;
            color: #666;
        }

        .task-meta-item {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .task-description {
            color: #666;
            font-size: 14px;
            line-height: 1.5;
            margin-bottom: 15px;
            max-height: 60px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .task-status {
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 500;
            display: inline-block;
            margin-bottom: 15px;
        }

        .status-todo {
            background: #fff3cd;
            color: #856404;
        }

        .status-in-progress {
            background: #d4edda;
            color: #155724;
        }

        .status-completed {
            background: #d1ecf1;
            color: #0c5460;
        }

        .status-cancelled {
            background: #f8d7da;
            color: #721c24;
        }

        .task-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
        }

        .modal-content {
            background-color: white;
            margin: 5% auto;
            padding: 0;
            border-radius: 8px;
            width: 90%;
            max-width: 600px;
            max-height: 90vh;
            overflow-y: auto;
        }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h3 {
            margin: 0;
        }

        .close {
            color: #aaa;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }

        .close:hover {
            color: #000;
        }

        .modal-body {
            padding: 20px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
        }

        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
        }

        .form-group textarea {
            height: 80px;
            resize: vertical;
        }

        .form-row {
            display: flex;
            gap: 15px;
        }

        .form-row .form-group {
            flex: 1;
        }

        .modal-footer {
            padding: 20px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .loading {
            text-align: center;
            padding: 40px;
            color: #666;
        }

        .error {
            color: #dc3545;
            background: #f8d7da;
            padding: 10px;
            border-radius: 4px;
            margin-bottom: 15px;
        }

        .success {
            color: #155724;
            background: #d4edda;
            padding: 10px;
            border-radius: 4px;
            margin-bottom: 15px;
        }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #666;
        }

        .empty-state h3 {
            margin-bottom: 10px;
            color: #999;
        }

        .filter-tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

        .filter-tab {
            padding: 8px 16px;
            border: 1px solid #ddd;
            background: white;
            border-radius: 20px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .filter-tab.active {
            background: #007bff;
            color: white;
            border-color: #007bff;
        }

        .filter-tab:hover {
            background: #f8f9fa;
        }

        .filter-tab.active:hover {
            background: #0056b3;
        }

        @media (max-width: 768px) {
            .container {
                padding: 0 10px;
            }
            
            .toolbar {
                flex-direction: column;
                align-items: stretch;
            }
            
            .search-box {
                flex-direction: column;
            }
            
            .search-box input {
                width: 100%;
            }
            
            .tasks-grid {
                grid-template-columns: 1fr;
            }
            
            .modal-content {
                width: 95%;
                margin: 10px auto;
            }
            
            .form-row {
                flex-direction: column;
            }
            
            .task-actions {
                justify-content: center;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>📋 任务中心</h1>
    </div>

    <div class="container">
        <!-- 工具栏 -->
        <div class="toolbar">
            <div class="search-box">
                <input type="text" id="searchInput" placeholder="搜索任务标题或描述...">
                <select id="statusFilter">
                    <option value="">所有状态</option>
                    <option value="TODO">待开始</option>
                    <option value="IN_PROGRESS">进行中</option>
                    <option value="COMPLETED">已完成</option>
                    <option value="CANCELLED">已取消</option>
                </select>
                <select id="priorityFilter">
                    <option value="">所有优先级</option>
                    <option value="URGENT">紧急</option>
                    <option value="HIGH">高</option>
                    <option value="MEDIUM">中</option>
                    <option value="LOW">低</option>
                </select>
                <button class="btn btn-primary" onclick="searchTasks()">🔍 搜索</button>
                <button class="btn btn-primary" onclick="loadTasks()">🔄 刷新</button>
            </div>
            <button class="btn btn-success" onclick="showCreateModal()">➕ 新建任务</button>
        </div>

        <!-- 筛选标签 -->
        <div class="filter-tabs">
            <div class="filter-tab active" onclick="filterTasks('all')">全部任务</div>
            <div class="filter-tab" onclick="filterTasks('my')">我的任务</div>
            <div class="filter-tab" onclick="filterTasks('urgent')">紧急任务</div>
            <div class="filter-tab" onclick="filterTasks('overdue')">逾期任务</div>
        </div>

        <!-- 任务列表 -->
        <div id="tasksContainer">
            <div class="loading">加载中...</div>
        </div>
    </div>

    <!-- 创建/编辑任务模态框 -->
    <div id="taskModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 id="modalTitle">新建任务</h3>
                <span class="close" onclick="closeModal()">&times;</span>
            </div>
            <div class="modal-body">
                <div id="modalError" class="error" style="display: none;"></div>
                <form id="taskForm">
                    <div class="form-group">
                        <label for="taskName">任务标题 *</label>
                        <input type="text" id="taskName" name="taskName" required>
                    </div>
                    
                    <div class="form-group">
                        <label for="description">任务描述</label>
                        <textarea id="description" name="description" placeholder="请输入任务描述..."></textarea>
                    </div>
                    
                    <div class="form-row">
                        <div class="form-group">
                            <label for="projectId">所属项目 *</label>
                            <select id="projectId" name="projectId" required>
                                <option value="">请选择项目</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="assigneeId">负责人 *</label>
                            <select id="assigneeId" name="assigneeId" required>
                                <option value="">请选择负责人</option>
                            </select>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="form-group">
                            <label for="priority">优先级 *</label>
                            <select id="priority" name="priority" required>
                                <option value="LOW">低</option>
                                <option value="MEDIUM" selected>中</option>
                                <option value="HIGH">高</option>
                                <option value="URGENT">紧急</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="status">任务状态 *</label>
                            <select id="status" name="status" required>
                                <option value="TODO" selected>待开始</option>
                                <option value="IN_PROGRESS">进行中</option>
                                <option value="COMPLETED">已完成</option>
                                <option value="CANCELLED">已取消</option>
                            </select>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label for="dueDate">截止日期 *</label>
                        <input type="date" id="dueDate" name="dueDate" required>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="closeModal()">取消</button>
                <button type="button" class="btn btn-success" onclick="saveTask()">保存</button>
            </div>
        </div>
    </div>

    <script src="task-center.js"></script>
</body>
</html>
